insheet using bdi_s.csv, clear
set more off
g age1972_sq = age1972^2 
la var dm11 "Subject's ed. (yrs.)"
la var dm12 "Father's ed. (yrs.)"
la var age1972 "Age"
la var age1972_sq "Age squared"
la var logitsurv "Logit survival pr."
la var exrebel "Participate in rebellion (0/1)"

encode adm1npre, g (adm1npre_n)

* Logistic regressions

eststo clear
eststo: xi: logit exrebel age1972 age1972_sq  dm11      i.adm1npre           [pweight=pweight], cluster(adm2id)
eststo: xi: logit exrebel age1972 age1972_sq       dm12 i.adm1npre           [pweight=pweight], cluster(adm2id)
eststo: clogit    exrebel age1972 age1972_sq  dm11,     group(adm1npre_n) cluster(adm1npre_n)
eststo: clogit    exrebel age1972 age1972_sq  dm12,     group(adm1npre_n) cluster(adm1npre_n)
eststo: xi: logit exrebel age1972 age1972_sq  dm11      i.adm1npre logitsurv [pweight=pweight], cluster(adm2id)
eststo: xi: logit exrebel age1972 age1972_sq       dm12 i.adm1npre logitsurv [pweight=pweight], cluster(adm2id)
eststo: xi: logit exrebel age1972 age1972_sq  dm12 dm11 i.adm1npre logitsurv [pweight=pweight], cluster(adm2id)

g Iage12 = age1972>12
g Iage16 = age1972>16
g dm12XIage12 = dm12*Iage12
g dm12XIage16 = dm12*Iage16

la var Iage12 "Age in 1972 > 12"
la var Iage16 "Age in 1972 > 16"
la var dm12XIage12 "Father's ed. (yrs.) X Age in 1972 > 12"
la var dm12XIage16 "Father's ed. (yrs.) X Age in 1972 > 16"

eststo: xi: logit exrebel age1972 Iage12  dm12 dm12XIage12   i.adm1npre  logitsurv         [pweight=pweight], cluster(adm2id)
eststo: xi: logit exrebel age1972 Iage16  dm12 dm12XIage16   i.adm1npre   logitsurv        [pweight=pweight], cluster(adm2id)

esttab using "tables/logit-out.tex", replace keep(age1972 age1972_sq Iage12 Iage16 dm11 dm12 dm12XIage12 dm12XIage16 logitsurv) b(3) se(3) l nomti addnotes("Logistic regression coefficients reported." "Models 1-2 and 5-9 are weighted logistic regression with pre-war province fixed effects." "(Weights are the same as those used in the main text.)" "Models 3-4 are unweighted conditional logistic regressions grouping by pre-war province." "Standard errors account for commune-level clustering except for models 3-4, which account for grouping factor clustering." "Models 2 and 4 use age-specific fixed effects.")
